<template>
    <div>
        <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="($router.push('/home/index'))" />
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in categories" :title="item.cat_name" />
                </van-sidebar>

            </van-col>

            <van-col span="18">
              <lbt :images="imageList" imagewidth="200px" imageheight="100px"></lbt>
                <div v-for="item in categories[active]?.children">
                    <h4>{{ item.cat_name }}</h4>
                    <router-link :to="{ name: 'list', params: { query: item.cat_name } }">
                        <van-grid :column-num="4">
                            <van-grid-item v-for="item in item.children" :icon="item.cat_icon" :text="item.cat_name" />
                        </van-grid>

                    </router-link>

                </div>
            </van-col>
        </van-row>

    </div>
</template>

<script setup>
import lbt from '@/components/lbt.vue';
const imageList = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-5.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-6.jpeg',
];
import { ref } from 'vue';
import { categoriesApi } from '@/api/api';
let categories = ref([])
categoriesApi().then(res => {
    console.log('分类数据', res)
    categories.value = res.data.message
})
let active = ref(0)

</script>

<style lang="scss" scoped></style>